<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户小贷授信记录 列表</title>
<jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
        	<%-- <div class="FXBR">
	            <div class="fieldBox">
	                <div class="label">用户ID</div>
	                <div class="field">
	                    <input name="usrId" id="usrId" type="text" class="ui-textbox" value="" ligerui="width: 160">
	                </div>
	                <div class="label">车辆ID</div>
	                <div class="field">
	                	<input name="carId" id="carId" type="text" class="ui-textbox" value="" ligerui="width: 160">
	                </div>
	                <div class="label">是否作废</div>
	                <div class="field">
	                	<select name="isDel" id="isDel">
	                		<option value="">--全部--</option>
	                		<option value="1">是</option>
	                		<option value="0">否</option>
	                	</select>
	                </div>
	            </div>
            </div>
            <div class="FXBR">
            	<div class="fieldBox">
	                <div class="label">挂靠公司</div>
	                <div class="field">
	                    <input name="compNm" id="compNm" type="text" class="ui-textbox" value="" ligerui="width: 160">
	                </div>
	                <div class="label">授信时间</div>
	                <div class="field">
	                	<input name="creditTmStr" id="creditTmStr" type="text" class="ui-datepicker" value="" ligerui="width: 160">
	                </div>
	            </div>
	        </div> --%>
	        <div class="FXBR">
            	<div class="fieldBox">
	                <div class="label">手机号</div>
	                <div class="field">
	                <input name="currentUserId" id="currentUserId" type="hidden" value="${currentUserId }" ligerui="width: 160">
	                    <input name="usrNm" id="usrNm" type="text" class="ui-textbox" value="" ligerui="width: 160">
	                </div>
	                <div class="label">身份证号</div>
	                <div class="field">
	                	<input name="certNo" id="certNo" type="text" class="ui-textbox" value="" ligerui="width: 160">
	                </div>
					<%--<div class="label">领取人ID</div>
					<div class="field">
						<input name="claim" id="claim" type="text" class="ui-textbox" value="" ligerui="width: 160">
					</div>--%>
					<div class="label">审核状态</div>
					<div class="field">
						<select name="auditVisitStatus" id="auditVisitStatus">
							<option value="" selected>--全部--</option>
							<option value="1">待审核</option>
							<option value="2">通过</option>
							<option value="3">拒单</option>
							<option value="4">驳回</option>
						</select>
					</div>

					<div class="label">领取人</div>
					<div class="field">
						<input name="claim" id="claim" type="text" class="ui-textbox" value="" ligerui="width: 160">
					</div>
					<div class="label">领取状态</div>
					<div class="field">
						<select name="operationStatus" id="operationStatus">
							<option value=" " selected>请选择</option>
							<option value="1" >待领取</option>
							<option value="2">查看信审回访</option>
							<option value="3">添加信审回访</option>
						</select>
					</div>
	            </div>
	        </div>
            <div class="clearFix"></div>
	            <div class="btnsBox formBtns notRight">
	                <span id="searchBtn" onclick="searchBtn();" class="sq-button-round">查询</span>
	                <span id="clearBtn" onclick="clearBtn();" class="sq-button-round">清空</span>
	                <!-- <span id="addBtn" onclick="add();" class="sq-button-round">新增</span> -->
	               <!--  <span id="updateBtn" onclick="update();" class="sq-button-round">修改</span> -->
	                <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
	            </div>
        	</div>
        </form>
    </div>
</div>
<div id="mcrCstCreditRecgrid" class="sq-grid"></div>
</div>

<script type="text/javascript">
	var grid = null;
	$(function () {
	    initForm();
		initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
		//initEvent();
	});
	
	function initEvent(){
		 $("#redisBtn").click(function(event) {
			 var url = '<%=path%>/mcr/mcrCstCreditRec/getRedisInfo.do';
			 AjaxUtils.ajaxGet(url, {}, redisCallback);
	    });
	}
	
	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}
	
	//查询按钮事件
	function searchBtn(){
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	}
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
        var data = form.getData();
        return data;
	}
	
	//初始化列表
	function initGrid(){
		$("#mcrCstCreditRecgrid").ligerGrid({
	    	url: '<%=path%>/mcr/mcrCstCreditRec/initList.do',
	    	method : 'post',
	    	isSingleCheck: false,
	    	parms:getSearchParams(),
	        columns: [
	            { display: '客户姓名', name: 'custName', width: 120 , align:'left', enabledSort:true,},
	            { display: '身份证号', name: 'certNo', width: 160, enabledSort:true },
	            { display: '手机号', name: 'refMp', width: 120, enabledSort:true},
	            { display: '申请时间', name: 'crtTm', width: 120, render:renderDate, enabledSort:true, },
	            /* { display: '是否有效', name: 'isValid', width: 120, enabledSort:true,
	            	render:function(rowData){
                        if(rowData.isValid=="1"){
                            return "是";
                        }else{
                            return "否";
                        }
                    }	
	            }, */
	            { display: '审核人', name: 'auditorName', width: 150, enabledSort:true },
	            { display: '审核时间', name: 'visitCrtTm', width: 150, render:renderDate, enabledSort:true },
	            { display: '状态', name: 'auditVisitNm', width: 120, enabledSort:true },
	            { display: '操作时间', name: 'mdfTm', width: 150, render:renderDate, enabledSort:true },
	            { display: '领取人', name: 'claimNm', width: 120, enabledSort:true },
	            getGridOperColumnContent()
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:true,
	        rownumbers:true
	    });
	    grid = liger.get("mcrCstCreditRecgrid");
	    grid.setHeight(100);
	}
	
	
  	//Grid操作列
    function getGridOperColumnContent(){
  		var currentUserId = $("#currentUserId").val();
    	var data = {
                display: '操作',
                isSort: false,
                width: 280,
                render: function (rowdata, rowindex, value){
                     /* h='<a class="sq-button-hasicon" href="javascript:deleteRow(';
                        h+="'"+rowdata.id+"'";
                        h+=",'mid_man_grid_id'"
                        h+=")\"><i class=\"sqBtnIco_7\"></i>删除</a>" */
                        
                    var h='<a class="sq-button-hasicon" href="javascript:modifyRow(';
                        h+="'"+rowdata.id+"'";
                        h+=",'mid_man_grid_id'"
                        h+=")\"><i class=\"sqBtnIco_4\"></i>修改</a>"
                        
                    var m='<a class="sq-button-hasicon" href="javascript:audReturnVisit(';
                        m+="'"+rowdata.id+"',";
                        m+="'"+rowdata.carId+"',";
                        m+="'"+rowdata.usrId+"',";
                        m+="'"+'0'+"'";
                        m+=",'mid_man_grid_id'"
                        m+=")\"><i class=\"sqBtnIco_7\"></i>添加信审回访</a>"
                    var n='<a class="sq-button-hasicon" href="javascript:audReturnVisit(';
                    	n+="'"+rowdata.id+"',";
                    	n+="'"+rowdata.carId+"',";
                    	n+="'"+rowdata.usrId+"',";
                        n+="'"+'1'+"'";
                        n+=",'mid_man_grid_id'"
                        n+=")\"><i class=\"sqBtnIco_7\"></i>查看信审回访</a>";
                   	var z='<a class="sq-button-hasicon" href="javascript:cancel(';
                        z+="'"+rowdata.id+"'";
                        z+=",'mid_man_grid_id'"
                        z+=")\"><i class=\"sqBtnIco_7\"></i>作废</a>"
                    var y='<a class="sq-button-hasicon" href="javascript:claim(';
                        y+="'"+rowdata.id+"'";
                        y+=",'mid_man_grid_id'"
                        y+=")\"><i class=\"sqBtnIco_7\"></i>领取</a>"
                   	var returnStr = '';  
                   /* 	if(rowdata.isDel == 0){
                       	returnStr = z;
                    } */
                   	if(rowdata.isCredit == 1){
	                   	if(rowdata.claim != null && rowdata.claim != ''){
	                   		if(rowdata.returnVisistId != null && rowdata.returnVisistId != ''){
	                       		returnStr = returnStr + n;
	                       	}else if(currentUserId == rowdata.claim){
	                       		returnStr = returnStr + m;
	                       	}
	                   	}else{
	                   			returnStr = returnStr + y;
	                   	}
                   	}
                   	return returnStr;
                }
            }
    	return data;
	}
  	
  	//删除数据
  	function deleteRow(_id){
  		$.ligerDialog.confirm('确定删除吗?', function (flag) {
			if(flag == false)return;
			var url = '<%=path%>/mcr/mcrCstCreditRec/removeById.do';
			AjaxUtils.ajaxPost(url, {id:_id}, delCallback);
		});
  	}
  	//作废数据
  	function cancel(_id){
  		$.ligerDialog.confirm('确定作废吗?', function (flag) {
			if(flag == false)return;
			var url = '<%=path%>/mcr/mcrCstCreditRec/cancel.do';
			AjaxUtils.ajaxPost(url, {id:_id}, delCallback);
		});
  	}
  	
  //领取记录
  	function claim(_id){
  		$.ligerDialog.confirm('确定领取记录吗?', function (flag) {
			if(flag == false)return;
			var url = '<%=path%>/mcr/mcrCstCreditRec/claim.do';
			AjaxUtils.ajaxPost(url, {id:_id}, delCallback);
		});
  	}
  	
  	//删除回调
  	function delCallback(msg){
  		if(msg.success == 1){
			UIUtils.alertSuccess(msg.info);
			var form = new liger.get("searchBar");
			var data = form.getData();
			for (name in data){
				grid.setParm(name,data[name]);
			};
			grid.reload($('.pcontrol input', grid.toolbar).val());
		 }else{
			UIUtils.alertError(msg.info);
		 }
  	}
  	
  	//修改方法
  	function modifyRow(_id){
        $.ligerDialog.SQopen({
            width: 800,
            height:200,
            title : '修改',
            url:'<%=path%>/mcr/mcrCstCreditRec/toAddPage.do?id='+_id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
	                text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
	                onclick: function (item, Dialog) {
	                    //在子页面里绑定 frameElement.dialog.onOk = function () {}
	                    if (Dialog.onOk) {
	                    	Dialog.onOk();
	                    }
	                }
            		}, {
                    text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
  	}
  	
	//新增
	function add(){
		$.ligerDialog.SQopen({
            width: 800,
            height:200,
            title : '新增',
            url:'<%=path%>/mcr/mcrCstCreditRec/toAddPage.do',
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
                    text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onOk = function () {}
                        if (Dialog.onOk) {
                        	Dialog.onOk();
                        }
                    }
                }, {
                    text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) {
                        	Dialog.onCancel()
                        };
                    }
                }
            ]
        });
	}
	
	//查看详情
	function showDetail(_id){
		$.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 800,
            height:200,
            title : '详情',
            url:'<%=path%>/mcr/mcrCstCreditRec/toDetailPage.do?id='+_id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [ {
                    text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) {
                        	Dialog.onCancel();
                        }
                    }
                }
            ]
        });
	}
	
  	//redis回调
  	function redisCallback(msg){
  		if(msg.success == 1){
			 UIUtils.alertSuccess(msg.data);
		 }else{
			 UIUtils.alertError(msg.info);
		 }
  	}
	
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}
	
	//清空按钮事件
	function clearBtn(){
		 $("#resetBtn").click();  //重置 input-text
		 var form = new liger.get("searchBar");
		 form.setData({  //重置select等特殊表单
		    "name":""
		  });
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	
	function audReturnVisit(_id, carId, usrId, isDetail){
		//回调刷新列表
		var callback = function () {
			grid.reload();
		};
		
        $.ligerDialog.SQopen({
            width: 1180,
            height: 1300,
            title: '信审回访信息',
            url:'<%=path%>/audit/audReturnVisit/toAddmcrCstCreditRecPage.do?projectId='+_id+'&carId='+carId+'&usrId='+usrId+'&isDetail='+isDetail
        });
		<%-- Add_navTab('audReturnVisit'+_id,'信审回访信息','<%=path%>/audit/audReturnVisit/toAddmcrCstCreditRecPage.do?projectId='+_id+'&isDetail='+isDetail); --%>
	}
	
	//修改
	function update(){
		var selectedRows = grid.getSelectedRows();
		if(selectedRows.length != 1){
			UIUtils.alertError("请选择一条数据");
			return;
		}
		
		var _id = selectedRows[0].id;
		Add_navTab('Comp_2','修改','<%=path%>/mcr/mcrCstCreditRec/toAddPage.do?id='+_id);
		
		<%-- $.ligerDialog.SQopen({
            width: 800,
            height:200,
            title : '修改',
            url:'<%=path%>/mcr/mcrCstCreditRec/toAddPage.do?id='+_id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
	                text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
	                onclick: function (item, Dialog) {
	                    //在子页面里绑定 frameElement.dialog.onOk = function () {}
	                    if (Dialog.onOk) {
	                    	Dialog.onOk();
	                    }
	                }
            		}, {
                    text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        }); --%>
	}
	
</script>

</body>
</html>